package a66weding.com.jiehuntong.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.application.DataWareHourse;
import a66weding.com.jiehuntong.application.GlobalApplication;
import a66weding.com.jiehuntong.common.utils.stubar.StatusBarUtil;

/**
 * 我的-设置-账号安全界面
 */
public class MeSetNumSafeActivity extends MeBaseActivity implements View.OnClickListener {
    private LinearLayout mBackLay;
    private TextView mBackContentTv;
    private TextView mHeaderTitleTv;
    private TextView mRealnameTv;
    private TextView mPhoneNumberTv;
    private RelativeLayout mHeaderRightRlay;
    private RelativeLayout mRealNameRlay;
    private RelativeLayout mBindNumRlay;
    private RelativeLayout mSetPasswordRlay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_me_userinfo_safe);
        ((GlobalApplication)getApplication()).getActivityManager().addActivity("MeSetNumSafeActivity",this);
        initview();
    }



    private void initview() {

        mBackLay = (LinearLayout) findViewById(R.id.llay_header_back);
        mBackContentTv = (TextView) findViewById(R.id.tv_header_backcontent);
        mHeaderTitleTv = (TextView) findViewById(R.id.tv_header_title);
        mHeaderRightRlay = (RelativeLayout) findViewById(R.id.rlay_header_rightfunc);
        mRealNameRlay = (RelativeLayout) findViewById(R.id.rlay_me_set_realname);
        mBindNumRlay = (RelativeLayout) findViewById(R.id.rlay_me_set_bindNum);
        mSetPasswordRlay = (RelativeLayout) findViewById(R.id.rlay_me_set_passWord);
        mRealnameTv = (TextView) findViewById(R.id.tv_real_name);
        mPhoneNumberTv = (TextView) findViewById(R.id.tv_phone_number);

        mBackContentTv.setText("返回");
        mHeaderTitleTv.setText("个人信息");
        mHeaderRightRlay.setVisibility(View.GONE);

        mBackLay.setOnClickListener(this);
        mRealNameRlay.setOnClickListener(this);
        mBindNumRlay.setOnClickListener(this);
        mSetPasswordRlay.setOnClickListener(this);

    }

    /**
     * 显示内容调用的方法
     */
    @Override
    protected void onResume() {
        super.onResume();
        if(DataWareHourse.getInstance().getmUser().getData().get(0).getNvc_RealName() != null) {
            mRealnameTv.setText(DataWareHourse.getInstance().getmUser().getData().get(0).getNvc_RealName());
        }
        String phoneNumber = DataWareHourse.getInstance().getmUser().getData().get(0).getNvc_MobilePhone();
        String passPhone = phoneNumber.substring(0,3)+"****"+phoneNumber.substring(7,phoneNumber.length()); //把获取到的手机号中间四位隐藏
        mPhoneNumberTv.setText(passPhone);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.llay_header_back:
                finish();
                break;
            case R.id.rlay_me_set_realname:    //打开设置真实姓名的界面
                Intent intent = new Intent(this, MeUserRealnameActivity.class);
                intent.putExtra(MeBaseActivity.INTENTTO,MeBaseActivity.REALNAME);
                startActivity(intent);
                break;
            case R.id.rlay_me_set_bindNum:     //打开修改绑定号码的界面
                Intent intent2 = new Intent(this, MeYetBindPhoneActivity.class);
                intent2.putExtra(MeBaseActivity.INTENTTO,MeBaseActivity.REALNAME);
                startActivity(intent2);
                break;
            case R.id.rlay_me_set_passWord:    //打开设置登录密码的界面
                Intent intent3 = new Intent(this, MeSetNewpasswordActivity.class);
                intent3.putExtra(MeBaseActivity.INTENTTO,MeBaseActivity.REALNAME);
                startActivity(intent3);
                break;


        }
    }
}
